<template>
  <div class="main">
    <!-- 头部 -->
    <div class="header">
      <div class="sou" @click="showCollsed">
        <!-- 收缩按钮 -->
        <img v-show="!show" src="../../assets/imgs/sou.png" alt="" />
        <img v-show="show" src="../../assets/imgs/zhan.png" alt="" />
      </div>
      <div class="bun">
        <div class="headimgurl">
          <img :src="$imgUrl(headimgurl)" alt="" />
        </div>
        <div class="out" @click="out">退出</div>
      </div>
    </div>
    <!-- 主页面 -->
    <div class="container">
      <router-view></router-view>
    </div>
  </div>
</template>
<script>
import { getLoginUserMessageById } from "@/api/user";
import store from "@/store";
export default {
  data() {
    return {
      show: store.state.show,
      headimgurl: "",
    };
  },

  mounted() {
    this.getLoginUserMessageByIds();
  },
  methods: {
    getLoginUserMessageByIds() {
      getLoginUserMessageById().then((res) => {
        console.log(res.data);
        this.headimgurl = res.data.headimgurl;
      }).catch((err) => {
        console.log(err);
      })
    },
    //收缩展开
    showCollsed() {
      this.show = !this.show;
      store.commit("getShow", this.show);
      // console.log(store.state.show);
    },
    //退出
    out() {
      //去除本地缓存
      localStorage.clear();
      this.$router.push("/login");
    },
  },
};
</script>
<style lang="less" scoped>
.main {
  width: 100%;

  .header {
    width: 100%;
    background: #f9f8f8;
    height: 57px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-radius: 3px;

    .sou {
      width: 20px;
      height: 20px;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .bun {
      display: flex;
      align-items: center;

      .headimgurl {
        width: 35px;
        height: 35px;
        margin-right: 20px;

        img {
          width: 100%;
          height: 100%;
          border-radius: 50%;
        }
      }

      .out {
        background: #dedede;
        border-radius: 5px;
        padding: 5px 8px;
        font-size: 13px;
        cursor: pointer;
      }
    }

  }

  .breadcrumb {
    width: 100%;
    height: 35px;
    border-radius: 3px 3px 0 0;
    background: #f9f8f8;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);

    .el-breadcrumb {
      line-height: 35px;
      padding: 0 20px;
    }

    ::v-deep .el-breadcrumb__inner.is-link {
      color: #009af2;
    }
  }

  .container {
    padding: 10px;
    height: 100%;
  }
}
</style>